package br.furb.dao;

public class DaoFactory {

	public static DAO createDao(String s) {
		DAO retorno = null;
		
		try {
			retorno = (DAO) Class.forName(buildPackageString(s)).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		return retorno;
	}
	
	private static String buildPackageString(String classe) {
		String[] retorno = classe.split(".");
		
		return ("br.furb.dao." + (retorno.length != 0 ? retorno[retorno.length - 1] : classe));
	}
}
